package my.cn.bdqn.life;

import java.util.List;

import my.cn.bdqn.life.data.DataManager;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

public class MyAdapter extends BaseAdapter {
	
	List<DataManager.Show> list;
	private Context context;
	private LayoutInflater inflater;
	
	public MyAdapter(Context context, List<DataManager.Show> list) {
		this.list = list;
		this.context = context;
		inflater = LayoutInflater.from(context);
	}

	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return list.get(position);
	}

	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	public View getView(int position, View view, ViewGroup parent) {
		//Toast.makeText(MyAdapter.this, "88--"+list, 1).show();
		// TODO Auto-generated method stub
		DataManager.Show s=list.get(position);
		view=inflater.inflate(R.layout.show_item,null);
		ImageView photo=(ImageView)view.findViewById(R.id.show_photo);
		TextView name=(TextView)view.findViewById(R.id.show_name);
		TextView time=(TextView)view.findViewById(R.id.show_time);
		TextView addr=(TextView)view.findViewById(R.id.show_address);
		Log.d("image****", s.getImage()+"");
		Bitmap bm=BitmapFactory.decodeFile("/mnt/sdcard/freelife/"+s.getImage());
		photo.setImageBitmap(bm);
		name.setText(s.getName());
		time.setText(s.getTime());
		addr.setText(s.getAddr());
		return view;
	}

}
